import Qt 4.7

Item {
    id: container
    width: ListView.view.width; height: 60; anchors.leftMargin: 10; anchors.rightMargin: 10

    Rectangle {
        id: content
        anchors.centerIn: parent; width: container.width - 40; height: container.height - 10
        color: "transparent"
        smooth: true
        radius: 10
	
        Rectangle { anchors.fill: parent; anchors.margins: 3; color: "#91AA9D"; smooth: true; radius: 8 }

        Image {id:img; source: foldermodel.isFolder(index)?"images/dossier.jpg":"images/file.jpg";  smooth: true ; width:50 ; height:50}
        Text {
	  id: label
	  anchors.verticalCenter: content.verticalCenter
	  anchors.left:img.right
	  text: fileName
	  color: "#193441"
	  font.pixelSize: 30
	}	
    }

    
    
    

    MouseArea {
        id: mouseArea
        anchors.fill: parent
        hoverEnabled: true

        onClicked: {
            ListView.view.currentIndex = index;
            container.forceActiveFocus();
        }
    }

    Keys.onPressed: {
		if (event.key == Qt.Key_Return) {
		    console.log("selected :"  + fileName );
		    if(foldermodel.isFolder(index)) {
			console.log("dir:" + filePath);
			foldermodel.folder=filePath;
			event.accepted = true;
		    }else{
		      console.log("file:" + filePath);
		      event.accepted = true;
		    }
		}
    }
    
    states: State {
        name: "active"; when: container.activeFocus
        PropertyChanges { target: content; color: "#FCFFF5"; scale: 1.1 }
        PropertyChanges { target: label; font.pixelSize: 16 }
    }

    transitions: Transition {
        NumberAnimation { properties: "scale"; duration: 100 }
    }
}
